package com.github.ylt.protocol.http.server;

import com.github.ylt.protocol.http.HttpContext;
import com.github.ylt.protocol.http.handler.HttpHandler;

import java.net.InetSocketAddress;

/**
 * 扩展http1.1的协议使其支持SUBSCRIBE, UNSUBSCRIBE，NOTIFY请求
 * 目前不支持文件流，只支持纯文本
 * 目前支持的格式为：
 * text/xml,text/html
 * 支持soap的请求
 */
public abstract class Server {

    protected Server(){}

    public abstract void start();

    public static Server create(InetSocketAddress address) {
        return create(address,0);
    }

    public static Server create(InetSocketAddress address,int port){
        InetSocketAddress localAddress = new InetSocketAddress(address.getAddress(), port);
        return new ServerImpl("http", localAddress);
    }

    public abstract void stop();

    public abstract InetSocketAddress getAddress();

    public abstract int getPort();

    public abstract void bind(InetSocketAddress address);

    public abstract void close();

    public abstract boolean isClosed();

    public abstract HttpContext getContext();

    public abstract void createContext(String path);

    public abstract void removeContext(String path);

    public abstract void removeContext(HttpContext context);

}
